/***************************************************************************
 *   Copyright (C) 2008 by Philipp Müller <philipp.mueller@gmx.de>         *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA          *
 ***************************************************************************/

#ifndef WIDGETPLAYVIDEO_H
#define WIDGETPLAYVIDEO_H

#include <QWidget>
#include <QLabel>
#include <QToolBar>
#include <phonon/mediaobject.h>
#include <phonon/seekslider.h>
#include <phonon/volumeslider.h>

#include "vdrthread.h"
#include "iostream.h"
#include "widgetvideo.h"
#include "widgetosd.h"

class MainWindow;

/**
    @author Philipp Müller <philipp.mueller@gmx.de>
*/

class WidgetPlayVideo : public QWidget
{
        Q_OBJECT

    public:
        WidgetPlayVideo( MainWindow *mainWindow, VDR *vdr, QWidget *parent = 0 );
        ~WidgetPlayVideo();

        void initWidgetPlayVideo();
        void handleKeyPressEvent( QKeyEvent *event );

        WidgetOsd* osd() { return m_osd; };

        Phonon::MediaObject* mediaObject() { return m_mediaObject; };

    signals:
        void hideWindowTV( bool reloadChannellist = false );
        void hideWindowRecording( bool reloadRecordingslist = false );
        void hideWindowMedia( bool reloadMedialist = false );
        void setFullScreen( bool fullScreen = true );

    public slots:
        /** Stops playing video and recordings at mediaObject */
        void stopPlayVideo();

    private slots:
        void playTV();
        void playRecording();
        void playMedia();
        void stateChanged( Phonon::State newState, Phonon::State oldState );
        void metaStateChanged( Phonon::State newState, Phonon::State oldState );
        void fullScreenAction();

    private:
        void keyPressEvent( QKeyEvent *event );
        void switchChannel();
        void setupActions();
        void setupUi();
        void exit();

        Phonon::MediaObject *m_mediaObject;
        WidgetVideo *m_videoWidget;
        Phonon::SeekSlider *m_seekSlider;
        Phonon::VolumeSlider *m_volumeSlider;
        QWidget *m_metaDataWidget;
        WidgetOsd *m_osd;
        QLabel *m_channelNotAvailable;

        QToolBar *m_mediaButtonBar;
        QAction *m_playAction;
        QAction *m_pauseAction;
        QAction *m_stopAction;
        QAction *m_fullScreen;

        QLabel *m_titelLabel;
        QLabel *m_titelText;

        QLabel *m_artistLabel;
        QLabel *m_artistText;

        QLabel *m_albumLabel;
        QLabel *m_albumText;

        QLabel *m_yearLabel;
        QLabel *m_yearText;

        QLabel *m_genreLabel;
        QLabel *m_genreText;

        QLabel *m_trackLabel;
        QLabel *m_trackText;

        QLabel *m_descriptionLabel;
        QLabel *m_descriptionText;


        MainWindow *m_mainWindow;
        VDR *m_vdr;
        IOStream *m_ioStream;
        bool m_exit;
        bool m_startPlaying;
        bool m_switchChannel;
};

#endif
